package com.linln.common.utils;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: lizhou
 * Date: 2020/3/20
 * Time: 13:59
 * To change this template use File | Settings|Editor| File and Code Templates.
 * Description:
 */
public class LogUtil {
    public static void setAllLogLevel(String level){
        Level defaultLevel = Level.INFO;
        if(StringUtils.isNotEmpty(level)){
            defaultLevel = Level.toLevel(level);
        }
        LoggerContext loggerContext= (LoggerContext) LoggerFactory.getILoggerFactory();
        List<Logger> loggerList = loggerContext.getLoggerList();
        for(Logger logger : loggerList){
            logger.setLevel(defaultLevel);

        }
    }
}
